package com.hazardSoft.eStore.entities;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;

import com.hazardSoft.eStore.utils.QueryConstants;

@Entity
@NamedQueries({
	@NamedQuery(name = QueryConstants.QUERY_LIST_DEPARTMENTS, query = "FROM Department d ORDER BY d.name ASC"),
	@NamedQuery(name = QueryConstants.QUERY_SEARCH_DEPARTMENT_BY_ID, query = "FROM Department dep WHERE dep.id=?1")
})
public class Department implements Serializable {
	@Id
	private int id;

	@Lob
	private String name;

//	@OneToMany(mappedBy="department")
	@Transient
	private Collection<City> cityCollection;

	private static final long serialVersionUID = 1L;

	public Department() {
		super();
	}
	
	public Department(int id) {
		this.id = id;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Collection<City> getCityCollection() {
		return this.cityCollection;
	}

	public void setCityCollection(Collection<City> cityCollection) {
		this.cityCollection = cityCollection;
	}
	
	public String toString(){
		StringBuffer departmentString = new StringBuffer();
		
		departmentString.append("id: ["+this.getId()+"] ");
		departmentString.append("name: ["+this.getName()+"] ");
		
		return departmentString.toString();
	}
}
